export default {
  namespaced:true,
  state: {
    
    // token:''
   token: uni.getStorageSync('token') ,
   mobile:uni.getStorageSync('mobile'),
   // userInfo: {}
   userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}')
  },
  mutations:{
    setToken(state,str) {
      // console.log(str)
      state.token = str
      uni.setStorageSync('token',str)
    },
    setMobile(state,str) {
      state.mobile = str 
      uni.setStorageSync('mobile',str)
    },
    removeToke(state) {
      state.token = ''
      state.mobile = ''
      uni.removeStorageSync('token')
      uni.removeStorageSync('mobile')
    },
    setUserInfo(state,info) {
      state.userInfo = info
      uni.setStorageSync('userInfo',JSON.stringify(info))
      
    }
  },
  actions:{
   async getUserInfo(context) {
    const {data} = await uni.$http.get('/user/profile')
    console.log(data,'data.......')
     context.commit('setUserInfo',data.data)
      
    }
  }
}